import {ethers} from "ethers"

const ALCHEMY_MAINNET_URL = 'https://eth-mainnet.g.alchemy.com/v2/mkM5-GVJCs00ghRsjT7aU';
// 连接主网 provider
const provider = new ethers.JsonRpcProvider(ALCHEMY_MAINNET_URL);

// 识别某合约是否为ERC721合约，例如著名的NFT项目BAYC
// BAYC合约地址
const addressBAYC = "0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d"

// abi
const abiBAYC = [
    "function name() view returns (string)",
    "function symbol() view returns (string)",
    "function supportsInterface(bytes4) public view returns(bool)",
]
const contractBAYC = new ethers.Contract(addressBAYC, abiBAYC, provider)

console.log(`合约名称:${await contractBAYC.name()}`)
console.log(`合约代号:${await contractBAYC.symbol()}`)

const erc721InterfaceId = "0x80ac58cd"
const isERC721 = await contractBAYC.supportsInterface(erc721InterfaceId)
console.log(`合约是否为ERC721标准: ${isERC721}`)
